<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Cleanup old sessions</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="sessionhandler.destroy.html">« SessionHandler::destroy</a></li>
      <li style="float: right;"><a href="sessionhandler.open.html">SessionHandler::open »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.sessionhandler.html">SessionHandler</a></li>
    <li>Cleanup old sessions</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="sessionhandler.gc" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SessionHandler::gc</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">SessionHandler::gc</span> &mdash; <span class="dc-title">Cleanup old sessions</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-sessionhandler.gc-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>SessionHandler::gc</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$max_lifetime</code></span>): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span></span></div>

  <p class="para rdfs-comment">
   Cleans up expired sessions. Called randomly by PHP internally when a session starts or when
   <span class="function"><a href="function.session-start.html" class="function">session_start()</a></span> is invoked.  The frequency this is called is
   based on the <a href="session.configuration.html#ini.session.gc-divisor" class="link">session.gc_divisor</a> and
   <a href="session.configuration.html#ini.session.gc-probability" class="link">session.gc_probability</a> configuration
   directives.
  </p>
  <p class="para">
   This method wraps the internal PHP save handler defined in the
   <a href="session.configuration.html#ini.session.save-handler" class="link">session.save_handler</a> ini setting that was set
   before this handler was set by <span class="function"><a href="function.session-set-save-handler.html" class="function">session_set_save_handler()</a></span>.
  </p>
  <p class="para">
   If this class is extended by inheritance, calling the parent <code class="parameter">gc</code> method will invoke the
   wrapper for this method and therefore invoke the associated internal callback.  This allows this method to be
   overridden and or intercepted and filtered.
  </p>
  <p class="para">
   For more information on what this method is expected to do, please refer to the documentation at
   <span class="function"><a href="sessionhandlerinterface.gc.html" class="function">SessionHandlerInterface::gc()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-sessionhandler.gc-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">max_lifetime</code></dt>

    <dd>

     <p class="para">
      Sessions that have not updated for the last <code class="parameter">max_lifetime</code> seconds will be removed.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-sessionhandler.gc-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the number of deleted sessions on success,  或者在失败时返回 <strong><code>false</code></strong>.
   Note this value is returned internally to PHP for processing.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-sessionhandler.gc-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.1.0</td>
      <td>
       Prior to this version, the function returned <strong><code>true</code></strong> on success.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


</div></div></div></body></html>